# -*- coding: utf-8 -*-

from django.db import models
from core.models import CoreModel, table_prefix


class LoginLog(CoreModel):
    LOGIN_TYPE_CHOICES = ((1, "普通登录"),)
    username = models.CharField(
        null=True, blank=True, max_length=32, verbose_name="登录用户名"
    )
    ip = models.CharField(null=True, blank=True, max_length=32, verbose_name="登录ip")
    agent = models.TextField(null=True, blank=True, verbose_name="agent信息")
    browser = models.CharField(
        null=True, blank=True, max_length=200, verbose_name="浏览器名"
    )
    os = models.CharField(
        null=True, blank=True, max_length=200, verbose_name="操作系统"
    )
    continent = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="州"
    )
    country = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="国家"
    )
    province = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="省份"
    )
    city = models.CharField(null=True, blank=True, max_length=50, verbose_name="城市")
    district = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="县区"
    )
    isp = models.CharField(null=True, blank=True, max_length=50, verbose_name="运营商")
    area_code = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="区域代码"
    )
    country_english = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="英文全称"
    )
    country_code = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="简称"
    )
    longitude = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="经度"
    )
    latitude = models.CharField(
        null=True, blank=True, max_length=50, verbose_name="纬度"
    )

    class Meta:
        db_table = table_prefix + "system_loginlog"
        verbose_name = "登录日志"
        verbose_name_plural = verbose_name
        ordering = ("-create_time",)
